From: Geoffry Song Date: Fri, 22 Sep 2017 06:04:17 +0000 (-0700) Subject: Use memoized hashes when hashing Fingerprint. X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~6^2~42^2 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=04c30d61d84c762c8864b9f788abdc96058cfe02;p=cargo.git Use memoized hashes when hashing Fingerprint. The recursive hashing of dependencies can cause exponential blowup. We already have a memoized hash available, so use that, Merkle-tree-style. --- diff --git a/src/cargo/ops/cargo_rustc/fingerprint.rs b/src/cargo/ops/cargo_rustc/fingerprint.rs index 38cef8f1c..e4d2dd124 100644 --- a/src/cargo/ops/cargo_rustc/fingerprint.rs +++ b/src/cargo/ops/cargo_rustc/fingerprint.rs @@ -297,7 +297,14 @@ impl hash::Hash for Fingerprint { memoized_hash: _, ref rustflags, } = *self; - (rustc, features, target, profile, deps, local, rustflags).hash(h) + (rustc, features, target, profile, local, rustflags).hash(h); + + h.write_usize(deps.len()); + for &(ref name, ref fingerprint) in deps { + name.hash(h); + // use memoized dep hashes to avoid exponential blowup + h.write_u64(Fingerprint::hash(fingerprint)); + } } }